﻿using Furion;
using Furion.DynamicApiController;
using GWB.Application.Common;
using GWB.Application.System.UserManage.Dtos;
using GWB.Application.System.UserManage.UserService;
using GWB.Core;
using GWB.Core.Enum;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GWB.Application.System.UserManage
{
    [AllowAnonymous]
    [ApiDescriptionSettings("系统管理", Tag = "添加用户")]
   public class UserAppService:IDynamicApiController
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "添加用户", Code = AuthCode.Add)]
        public async Task<Result<UserOutDto>> Add(UserCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IUserService>().Add(inputDto);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [Authorization(Name = "删除", Code = AuthCode.Delete)]
        public async Task<bool> Delete(List<long> ids)
        {
            return await App.GetService<IUserService>().Delete(ids);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "查询", Code = AuthCode.Page)]
        public async Task<PageResult<UserOutDto>> Page(UserPageInputDto inputDto)
        {
            return await App.GetService<IUserService>().Page(inputDto);
        }


        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "修改", Code = AuthCode.Update)]
        public async Task<bool> Update(UserCreateOrUpdateInputDto inputDto)
        {
            return await App.GetService<IUserService>().Update(inputDto);
        }

        /// <summary>
        /// 编辑用户数据权限
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [Authorization(Name = "编辑用户数据权限", Code = AuthCode.None)]
        public async Task<bool> EditUserDataAuth(List<UserDataAuthDto> inputDto)
        {
            return await App.GetService<IUserService>().EditUserDataAuth(inputDto);
        }
    }
}
